package com.macro.mall.portal.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.macro.mall.portal.domain.LoanPackage;
import com.macro.mall.portal.service.IGuidancePriceService;
import com.macro.mall.portal.dao.GuidancePriceMapper;
import com.macro.mall.portal.domain.GuidancePrice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * 指导价表 服务实现类
 * </p>
 *
 * @author db
 * @since 2021-07-04
 */
@Service
public class GuidancePriceServiceImpl extends ServiceImpl<GuidancePriceMapper, GuidancePrice> implements IGuidancePriceService {

    @Autowired
    private GuidancePriceMapper guidancePriceMapper;

//    @Override
//    public Map<String, List<GuidancePrice>> selectList(GuidancePrice guidancePrice) {
//
//        QueryWrapper<GuidancePrice> wrapper = new QueryWrapper<>();
//        if (!StringUtils.isEmpty(guidancePrice.getDistrict())) {
//            wrapper.like("district", guidancePrice.getDistrict());
//        }
//        if (guidancePrice.getProject() != null) {
//            wrapper.like("project", guidancePrice.getDistrict());
//            wrapper.like("street", guidancePrice.getStreet());
//        }
////        wrapper.orderByDesc("money");
//
//        Map<String, List<GuidancePrice>> collect = guidancePriceMapper.selectList(wrapper).stream().collect(Collectors.groupingBy(GuidancePrice::getDistrict));
//
//        return collect;
//    }

    @Override
    public List<GuidancePrice> priceList(GuidancePrice guidancePrice) {
        QueryWrapper<GuidancePrice> wrapper = new QueryWrapper<>();
        wrapper.like("project", guidancePrice.getProject());
        List<GuidancePrice> priceList = guidancePriceMapper.selectList(wrapper);
        return priceList;
    }

    @Override
    public GuidancePrice selectList(GuidancePrice guidancePrice) {
        QueryWrapper<GuidancePrice> wrapper = new QueryWrapper<>();
        wrapper.eq("project", guidancePrice.getProject());
        GuidancePrice p = guidancePriceMapper.selectOne(wrapper);
        return p;
    }

    @Override
    public Integer person() {

        List<GuidancePrice> guidancePrices = guidancePriceMapper.selectList(null);
        return guidancePrices.size();
    }

}
